package com.dt76.smallloanbackenduser.controller.afterloan;


import com.dt76.smallloanbackenduser.pojo.afterloan.EWQualification;
import com.dt76.smallloanbackenduser.pojo.afterloan.EarlyWarningInfo;
import com.dt76.smallloanbackenduser.remote.afterloan.EarlyWarningRemote;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@Controller
public class EarlyWarningController {

    private final EarlyWarningRemote earlyWarningRemote;

    public EarlyWarningController(EarlyWarningRemote earlyWarningRemote) {
        this.earlyWarningRemote = earlyWarningRemote;
    }

    @GetMapping("/earlyWarning")
    public String jumpToEarlyManager() {
        return "/pages/afterloan/earlyWarningManager";
    }


    //对预警信息执行修改操作
    @PostMapping("/earlyWarning/modify")
    @ResponseBody
    public Integer jumpToEarlyEdit(@RequestBody EarlyWarningInfo form) {
        return earlyWarningRemote.jumpToEarlyEdit(form);
    }

    //获取分页的预警信息
    @PostMapping("/earlyWarning/list/{currentPage}/{pageSize}")
    @ResponseBody
    public Map<String, Object> getPageEWList(@RequestBody EWQualification q, @PathVariable Integer currentPage, @PathVariable Integer pageSize) {
        return earlyWarningRemote.getPageEWList(q, currentPage, pageSize);
    }

    //根据ID查询预警信息
    @GetMapping("/earlyWarning/getId/{id}")
    @ResponseBody
    public Map<String, Object> getById(@PathVariable String id) {
        return earlyWarningRemote.getById(id);
    }

    @PostMapping("/earlyWarning/add")
    @ResponseBody
    public Map<String, Object> addEW(@RequestBody EarlyWarningInfo form) {
        return earlyWarningRemote.addEW(form);
    }

}
